import Vue from "vue";

Vue.filter('filterImg', function (path) {
    return process.env.VUE_APP_IMG_SERVER + path;
})

Vue.filter('test', function (input) {
    return input + 'test';
})

Vue.filter('dateFilter', function (input) {
    let d = new Date(input);
    let year = d.getFullYear();
    let month = d.getMonth() < 9 ? "0" + (d.getMonth() + 1) : "" + (d.getMonth() + 1);
    let day = d.getDate() < 10 ? "0" + d.getDate() : "" + d.getDate();
    return (year + "-" + month + "-" + day);
})

Vue.filter('categoryFilter', function (index) {
    switch (index) {
        case '1':
            return '电影';
        case '2':
            return '电视剧';
        case '3':
            return '动漫';
        case '4':
            return '综艺';
        default:
            return '未知';
    }
})


Vue.filter('datetimeFilter', function (input) {
    let d = new Date(input);
    let year = d.getFullYear();
    let month = d.getMonth() < 9 ? "0" + (d.getMonth() + 1) : "" + (d.getMonth() + 1);
    let day = d.getDate() < 10 ? "0" + d.getDate() : "" + d.getDate();
    let hour = d.getHours() < 10 ? "0" + d.getHours() : "" + d.getHours();
    let minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : "" + d.getMinutes();
    let seconds = d.getSeconds() < 10 ? "0" + d.getSeconds() : "" + d.getSeconds();
    return (year + "-" + month + "-" + day + " " + hour + ":" + minutes + ":" + seconds);
})
